import { createApp } from 'vue'

import App from './App.vue'
import router from "./router/index";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import api from '../src/api'
 import store  from './store/index.js';
 import storage from './utils/index'

import QueryForm from './packages/QuerForm';
const app=createApp(App)
//在属性前添加一个$代表是程序员自己添加的，非系统自带
app.config.globalProperties.$api=api
//获取环境变量
app.directive("has",{
  //操作节点
  beforeMount:(el,binding)=>{
    
      // el 当前使用自定义指令的节点
      // binging 传递参数
      // el获取新增按钮，binging拿到‘user-create’字符串
      // 通过binging循环遍历actionlist，如果和el元素中有相同，=>有权限
      // 没有找到=>没权限
      let actionList=storage.getSession('actionList')
     
      let value=binding.value
   
      let permission=actionList.includes(value)
      if(!permission){
          // 没有找到=>没权限=>不显示
          el.style='display:none'
          setTimeout(()=>{
              el.parentNode.removeChild(el)
          },0)
      }
  }

});
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
app.use(router).use(ElementPlus).use(store).use(QueryForm).mount('#app')